/* 使用说明
	xxmessage(a,b,c,d);
	a:图片地址
	b:用户名
	c:下的订单数
	d:时间   */
	
	function orderInfo(bpath){
			var dataArray = [];
			$.ajax({
				type:'get',
				url:bpath+'/user/queryOrderAndOrder2Info',
				dataType:'json',
				success:function(data){
					dataArray = dataArray.concat(data.data.Order);
					dataArray = dataArray.concat(data.data.Orderresult);
					/*
					alert(dataArray);
					alert(dataArray[0].headimgurl);
					alert(dataArray[0].nick);
					alert(dataArray[0].orderDate);
					*/
					for(var i=0;i<dataArray.length;i++){
						var dt = sessionStorage.getItem(dataArray[i].orderDate);
						console.log("-------------"+dt);
						if(dt && dt != null){
							
						}else{
							sessionStorage.setItem(dataArray[i].orderDate, "1");
							var s = (new Date().getTime()-dataArray[i].orderDate-3000*i)/1000;
							var newDate = formatterDate(s);
							dataArray[i].orderDate = newDate;
							(function(a){
								window.setTimeout(function(){
									xxmessage(dataArray[a].headimgurl,dataArray[a].nick,"优惠订购成功",dataArray[a].orderDate);
								},3000*a);
							})(i)	
						}
					}//遍历数据每6秒显示一次
				}	
			});
			
			//。。。。发请求得到数据
			//。。。。发请求得到数据
			//var data=[{address:"图片地址",name:"1",content:"用户下了一单",time:"3秒前"},{address:"图片地址",name:"11",content:"用户下了一单",time:"3秒前"},{address:"图片地址",name:"14",content:"用户下了一单",time:"4秒前"},{address:"图片地址",name:"15",content:"用户下了一单",time:"5秒前"},{address:"图片地址",name:"17",content:"用户下了一单",time:"6秒前"}];
						
			//30秒调用一次 定时器
	}
	
	function formatterDate(s){
		//分钟
		var m = s/60;
		//小时
		var h = m/60;
		//天
		var d = h/24;
		if(s<0){
			return "刚刚" 
		}
		if(s<60 && s>0){
			return parseInt(s)+"秒前" 
		}
		if(m<60){
			return parseInt(m)+"分钟前" 
		}
		if(h<24){
			return parseInt(h)+"小时前" 
		}
		return parseInt(d)+"天前" 
	}